package com.exam.api.modules.goods.controller;

import com.exam.api.common.web.TinyResponse;
import com.exam.api.modules.goods.domain.TblProductInfo;
import com.exam.api.modules.goods.mapper.TblProductInfoMapper;
import com.exam.api.modules.goods.service.TblProductInfoService;
import com.exam.api.modules.goods.vo.ProductSkuVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "(管理端) 第三方商品相关接口", description = "(管理端) 第三方商品相关接口")
@RestController
@RequestMapping("/manager/goods")
@TinyResponse
public class GoodsManagerController {

    @Resource
    private TblProductInfoService tblGoodsInfoService;
    @Resource
    private TblProductInfoMapper tblProductInfoMapper;
    @Operation(summary = "查询第三方商品", description = "分页查询第三方商品")
    @PostMapping("/list")
    public List<TblProductInfo> listGoodsInfo(@RequestBody TblProductInfo condition) {
        return tblGoodsInfoService.lambdaQuery().orderByDesc(TblProductInfo::getCreateTime).list();
    }

    @Operation(summary = "查询第三方商品skuList", description = "分页查询第三方商品")
    @PostMapping("/skuList")
    public List<ProductSkuVO> listSkuInfo() {
        return tblProductInfoMapper.selectAllSkuList();
    }

    @Parameter(name = "id", description = "第三方商品ID", in = ParameterIn.PATH, required = true)
    @Operation(summary = "根据ID查询第三方商品", description = "根据ID查询第三方商品")
    @PostMapping("/{id}")
    public TblProductInfo getTblGoodsInfoById(@PathVariable("id") Long id) {
        return tblGoodsInfoService.getById(id);
    }

}
